package com.lyz.dataStructure.algorithm.腾讯面试2020;/**
 * @Author:759057893@qq.com Lyz
 * @Date: ${Date} 21:24
 * @Description:
 **/

import java.util.Scanner;

/**
 *@Author:759057893@qq.com Lyz
 *@Date: 2019/9/20 21:24
 *@Description:
 **/
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        for(int i=0;i<t;i++){
            int length=sc.nextInt();
            String str=sc.next();
            boolean  p=yesOrNo(str);
            if(p==true){
                System.out.println("YES");
            }else{
                System.out.println("NO");
            }
        }

    }
    public static boolean yesOrNo(String s){
        if(s.length()==0||s==null){
            return false;
        }
        boolean flag = false;
        int i = 0;
        while (s.length()-i>=11){
            if(s.charAt(i)=='8'){
                flag = true;
                break;
            }else {
                i++;
            }
        }
        return flag;
    }
}
